# RESTful DDS is a prototyping effort to demonstrate how DDS could be combined
# with HTTP clients, extending the realm of pub/sub distribution to true wide
# area networking.
#
# Copyright (C) 2009 PrismTech Ltd.
# reinier.torenbeek@gmail.com
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License Version 3 dated 29 June 2007, as published by the
# Free Software Foundation.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with restful-dds; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA

# Change the settings below if you want to use external jars from a different
# location. By default, the jars included with the project are used
# as well as the standard jar location for OpenSplice.

# First test OSPL_HOME env var, required for this script to run properly
if [ -z "$OSPL_HOME" ]
then
  echo OpenSplice environment does not appear to be set up -- exiting
  exit
fi

# External jars required
RESTLET_INTF_JAR=external/org.restlet.jar
RESTLET_IMPL_JAR=external/com.noelios.restlet.jar
GSON_JAR=external/gson-1.4.jar
DDS_JAR="$OSPL_HOME/jar/dcpssaj.jar"

# Built in test uses OpenSplice's example Chat.idl
TUTORIAL_DIR="$OSPL_HOME/examples/dcps/standalone/Java/Tutorial"
CHAT_IDL="$TUTORIAL_DIR/Chat.idl"


# Set GWT_HOME explicitly if you do not want it
# to be in PATH or CLASSPATH, either here or
# wherever you prefer, like:
# SET GWT_HOME=/opt/gwt-2.0.1

# First test whether the environment variable has
# already been set.

if [ -z "$GWT_HOME" ]
then
# Try to find GWT installation...
# First look in the PATH
  echo GWT_HOME not known, trying to find it in PATH
  GWT_FILE=gwt-user.jar

  for dir in ${PATH//:/ }
  do
    if [ -f "$dir/$GWT_FILE" ]
    then
      GWT_HOME=$dir
    fi
  done
fi

if [ -z "$GWT_HOME" ]
then
# GWT not found, looking in CLASSPATH as well
  echo GWT not found in PATH, trying CLASSPATH

  for dir in ${CLASSPATH//:/ }
  do
    if [ -f "$dir/$GWT_FILE" ]
    then
      GWT_HOME=$dir
    fi
  done
fi

if [ -z "$GWT_HOME" ]
then
  echo Can not find GWT anywhere, will not build the Battleship WebDemo
else
  echo GWT found, using $GWT_HOME
fi
